package com.mmy.service.ship.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mmy.dao.ship.TShipPlanRepository;
import com.mmy.dao.ship.VShipPlanRepository;
import com.mmy.domain.ship.TShipPlan;
import com.mmy.domain.ship.VShipPlan;
import com.mmy.service.ship.TShipPlanService;

@Service
public class TShipPlanServiceImpl implements TShipPlanService {

	@Autowired
	TShipPlanRepository tShipPlanRepository;
	@Autowired
	VShipPlanRepository vShipPlanRepository;

	/**
	 * 查找全部
	 * 
	 * @param
	 * @return
	 */
	public List<VShipPlan> findAll() {
		// TODO Auto-generated method stub
		return vShipPlanRepository.findAll();
	}

	/**
	 * 通过id查找
	 * 
	 * @param
	 * @return
	 */
	public VShipPlan findByID(int iPlanID) {
		// TODO Auto-generated method stub
		return vShipPlanRepository.findByID(iPlanID);
	}

	/**
	 * 获取计划单最大编码
	 * 
	 * @return 返回值说明 计划单编码
	 * @author 创建人 dingxd
	 * @date 创建日期 2020.11.16
	 */
	public String getMaxPlanID() {
		// 返回计划单最大编码
		Object objCode = tShipPlanRepository.getMaxPlanID();
		String strPlanID = "";
		if (objCode != null) {
			strPlanID = objCode.toString();
		}
		return strPlanID;
	}

	/**
	 * 新增id
	 * 
	 * @param
	 * @return
	 */
	public void save(int planID) {
		// TODO Auto-generated method stub
		tShipPlanRepository.save(planID);
	}

	/**
	 * 新增
	 * 
	 * @param
	 * @return
	 */
	public void save(TShipPlan tShipPlan) {
		// TODO Auto-generated method stub
		tShipPlanRepository.save(tShipPlan);
	}

	/**
	 * 删除
	 * 
	 * @param
	 * @return
	 */
	public void delShipPlan(List<Integer> lstPlanID) {
		// TODO Auto-generated method stub
		tShipPlanRepository.delShipPlan(lstPlanID);
	}

	/**
	 * 通过id查找
	 * 
	 * @param
	 * @return
	 */
	public TShipPlan findByPlanID(int iPlanID) {
		// TODO Auto-generated method stub
		return tShipPlanRepository.findByPlanID(iPlanID);
	}

	/**
	 * 通过name查找
	 * 
	 * @param
	 * @return
	 */
	public List<VShipPlan> findByName(String strShipName) {
		// TODO Auto-generated method stub
		return vShipPlanRepository.findByName(strShipName);
	}

	public List<VShipPlan> findByShipID(int iShipID) {
		// TODO Auto-generated method stub
		return vShipPlanRepository.findByShipID(iShipID);
	}

}
